<?php

class Category_model extends MY_Model {
    private $_table = 'category';

    function __construct() {
        parent::__construct();
        $this->table = 'category';
    }

    function getRows($where = array()) {
        if (count($where) > 0) {
            foreach ($where as $key => $value) {
                $this->db->where($key, $value);
            }
        }
        $this->db->order_by('id', 'ASC');
        $query = $this->db->get($this->_table);
        return $query->result();
    }
    function insertRow($data) {
        $this->db->insert($this->table, $data);
    }

    function updateRow($id, $data) {
        $this->db->where('id', $id);
        $this->db->update($this->table, $data);
    }

    function getRow($id) {
        $result = null;
        $this->db->where('id', $id);
        $query = $this->db->get($this->table);
        if ($query->num_rows == 1) {
            $result = $query->row();
        }
        return $result;
    }
}

?>
